/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
    font-size: 18px; /* 从16px增加到18px */
}

.container {
    width: 80vw;
    min-width: 1200px;
    max-width: 1800px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin: 0 auto;
}

/* Popup specific styles */
body.popup {
    margin: 0;
    padding: 0;
    background: white;
}

body.popup .container {
    width: 100%;
    min-width: auto;
    max-width: none;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.popup .main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

body.popup .editor-section {
    flex: 1;
    min-height: 0;
}

body.popup .input-panel,
body.popup .output-panel {
    height: auto;
    min-height: 0;
    flex: 1;
    overflow: hidden;
}

body.popup .panel-header {
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
}

body.popup .panel-buttons {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
    max-width: none;
}

body.popup .panel-buttons::-webkit-scrollbar {
    height: 4px;
}

body.popup .panel-buttons::-webkit-scrollbar-track {
    background: #f1f1f1;
}

body.popup .panel-buttons::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

body.popup .panel-buttons::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
}

.title-section {
    text-align: center;
    flex: 1;
}

.title-section h1 {
    font-size: 32px; /* 从28px增加到32px */
    margin-bottom: 5px;
    font-weight: 600;
}

.title-section p {
    opacity: 0.9;
    font-size: 18px; /* 从16px增加到18px */
    margin: 0;
}

.language-section {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
}

.language-section label {
    font-size: 16px; /* 从14px增加到16px */
    opacity: 0.9;
    white-space: nowrap;
}

.language-section select {
    padding: 4px 8px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 16px; /* 从14px增加到16px */
    min-width: 80px;
}

.language-section select:focus {
    outline: none;
    background: rgba(255,255,255,0.2);
}

.language-section option {
    background: #667eea;
    color: white;
}

/* Controls section */
.controls-section {
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.format-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.format-selector {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.format-selector label {
    font-weight: 500;
    color: #495057;
    font-size: 16px; /* 从14px增加到16px */
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.format-selector select {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: white;
    font-size: 18px; /* 从16px增加到18px */
    color: #495057;
    min-width: 100px;
}

.format-selector select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.convert-arrow {
    font-size: 24px; /* 从20px增加到24px */
    color: #667eea;
    font-weight: bold;
    margin: 0 10px;
}

.options-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Editor section */
.editor-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: #e9ecef;
}

.input-panel, .output-panel {
    background: white;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

#input-editor, #output-editor {
    flex: 1;
    min-height: 0;
    background: white;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    flex-shrink: 0;
    min-height: 60px;
}

.panel-header h3 {
    font-size: 18px; /* 从16px增加到18px */
    font-weight: 600;
    color: #495057;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    flex-shrink: 0;
    max-width: 60%;
}

/* Buttons */
.btn {
    padding: 10px 16px; /* 从8px 14px增加到10px 16px */
    border: none;
    border-radius: 4px;
    font-size: 16px; /* 从14px增加到16px */
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #e9ecef;
    color: #495057;
}

.btn:hover {
    background: #dee2e6;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a6fd8;
}

.btn-active {
    background: #28a745;
    color: white;
    transform: scale(0.95);
    transition: all 0.2s ease;
}

.btn-active:hover {
    background: #218838;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-sm {
    padding: 8px 12px; /* 从6px 8px增加到8px 12px */
    font-size: 14px; /* 从12px增加到14px */
    min-width: 60px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Textareas */
textarea {
    flex: 1;
    width: 100%;
    padding: 15px;
    border: none;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 17px; /* 从15px增加到17px */
    line-height: 1.5;
    resize: none;
    background: #fafbfc;
    color: #333;
}

textarea:focus {
    outline: none;
    background: #fff;
}

textarea[readonly] {
    background: #f8f9fa;
    color: #495057;
}

/* CodeMirror editor styles */
.CodeMirror {
    height: 100%;
    min-height: 100%;
    max-height: 100%;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 17px; /* 从15px增加到17px */
    line-height: 1.5;
    border: none;
    background: white;
    overflow: hidden;
}

.CodeMirror-scroll {
    padding: 10px;
    min-height: 100%;
    max-height: 100%;
    overflow-y: auto;
}

.CodeMirror-gutters {
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
}

.CodeMirror-linenumber {
    color: #6c757d;
    padding: 0 8px;
}

#input-editor .CodeMirror {
    border-right: 1px solid #e9ecef;
}

#output-editor .CodeMirror {
    background: #f8f9fa;
}

#output-editor .CodeMirror-scroll {
    background: #f8f9fa;
}

#output-editor .CodeMirror-cursor {
    display: none;
}

/* Error section */
.error-section {
    margin: 20px;
    padding: 12px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    color: #721c24;
}

.error-message {
    font-size: 18px; /* 从16px增加到18px */
}

.option {
    display: flex;
    align-items: center;
    gap: 6px;
}

.option input[type="checkbox"] {
    margin: 0;
}

.option label {
    font-size: 16px; /* 从14px增加到16px */
    color: #495057;
    cursor: pointer;
    white-space: nowrap;
}

.option select {
    padding: 4px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 16px; /* 从14px增加到16px */
    min-width: 60px;
}

/* Footer */
footer {
    padding: 15px 20px;
    text-align: center;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    font-size: 18px; /* 从16px增加到18px */
}

.standalone-link {
    color: #667eea;
    text-decoration: none;
    font-size: 18px; /* 从16px增加到18px */
}

.standalone-link:hover {
    text-decoration: underline;
}

/* Success message */
.success-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #d4edda;
    color: #155724;
    padding: 10px 15px;
    border-radius: 4px;
    border: 1px solid #c3e6cb;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}


body:not(.popup) .CodeMirror {
    height: 100%;
    max-height: 100%;
}

body:not(.popup) .CodeMirror-scroll {
    max-height: calc(500px - 60px); /* Subtract header height */
    overflow-y: auto;
}

/* Responsive design */
@media (max-width: 1400px) {
    .container {
        width: 90vw;
        min-width: 1000px;
    }
}

@media (max-width: 1200px) {
    .container {
        width: 95vw;
        min-width: 800px;
    }

    .controls-section {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .format-controls {
        justify-content: center;
    }

    .options-controls {
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .container {
        width: 98vw;
        min-width: auto;
    }

    .editor-section {
        grid-template-columns: 1fr;
        gap: 1px;
    }

    .input-panel, .output-panel {
        height: 300px;
    }

    .panel-header {
        padding: 10px 15px;
    }

    .controls-section {
        padding: 15px;
    }

    .format-controls {
        flex-direction: column;
        gap: 10px;
    }

    .convert-arrow {
        transform: rotate(90deg);
        margin: 5px 0;
    }
}

@media (max-width: 480px) {
    .container {
        margin: 10px;
        width: calc(100vw - 20px);
        min-width: auto;
    }

    .panel-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
        min-height: auto;
    }

    .panel-buttons {
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 5px;
    }

    .panel-buttons .btn-sm {
        flex-shrink: 0;
        white-space: nowrap;
    }

    .options-controls {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    body.popup .panel-header {
        position: relative;
    }
}
